package com.zhou.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * SleuthConfiguration
 *
 * @author zhouxianfeng
 * @date 2021-6-8
 */
@Configuration(proxyBeanMethods = false)
public class SleuthConfiguration {

    /**
     * 都是用来往span里写内容的
     * client 指的是发送请求 HttpClientResponseParser
     * server 指的是，本地的处理 HttpServerResponseParser
     *
     * @return
     * @Bean(name = HttpServerResponseParser.NAME)
     * HttpResponseParser myHttpResponseParser() {
     * return (response, context, span) -> {
     * Object unwrap = response.unwrap();
     * if (unwrap instanceof HttpServletResponse) {
     * HttpServletResponse resp = (HttpServletResponse) unwrap;
     * resp.addHeader("MyCustom", "Header");
     * }
     * };
     * }
     * @Bean(name = HttpServerRequestParser.NAME)
     * HttpRequestParser myHttpClientRequestParser() {
     * return (request, context, span) -> {
     * // Span customization
     * span.name(request.method());
     * span.tag("ClientRequest", "Tag");
     * Object unwrap = request.unwrap();
     * <p>
     * };
     * }
     */

/*    @Bean
    public FilterRegistrationBean staticAttributeSetFilter(
    ) {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(
                new StaticAttributeSetFilter());
        filterRegistrationBean.setDispatcherTypes(DispatcherType.ASYNC,
                DispatcherType.ERROR, DispatcherType.FORWARD, DispatcherType.INCLUDE,
                DispatcherType.REQUEST);
        filterRegistrationBean.setOrder(Ordered.LOWEST_PRECEDENCE);
        return filterRegistrationBean;
    }*/
    @Bean
    public StaticAttributeSetFilter staticAttributeSetFilter(
    ) {
        return new StaticAttributeSetFilter();
    }


}
